<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- Use Chrome Frame in IE -->
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <meta
      name="description"
      content="Sample photogrammetry and classification datasets both rendered with 3D Tiles."
    />
    <meta name="cesium-sandcastle-labels" content="Showcases, 3D Tiles" />
    <title>Cesium Demo</title>
    <script type="text/javascript" src="../Sandcastle-header.js"></script>
    <script
      type="text/javascript"
      src="../../../Build/CesiumUnminified/Cesium.js"
      nomodule
    ></script>
    <script type="module" src="../load-cesium-es6.js"></script>
  </head>
  <body
    class="sandcastle-loading"
    data-sandcastle-bucket="bucket-requirejs.html"
  >
    <style>
      @import url(../templates/bucket.css);
    </style>
    <div id="cesiumContainer" class="fullSize"></div>
    <div id="loadingOverlay"><h1>Loading...</h1></div>
    <div id="toolbar"></div>
    <script id="cesium_sandcastle_script">
      function startup(Cesium) {
        "use strict";
        //Sandcastle_Begin
        // An example of using a b3dm tilset to classify another b3dm tileset.
        const viewer = new Cesium.Viewer("cesiumContainer", {
          terrainProvider: Cesium.createWorldTerrain(),
        });

        // A normal b3dm tileset of photogrammetry
        const tileset = new Cesium.Cesium3DTileset({
          url: Cesium.IonResource.fromAssetId(40866),
        });
        viewer.scene.primitives.add(tileset);
        viewer.zoomTo(tileset);

        const classifcationTilesetUrl =
          "../../SampleData/Cesium3DTiles/Classification/Photogrammetry/tileset.json";
        // A b3dm tileset used to classify the photogrammetry tileset
        const classificationTileset = new Cesium.Cesium3DTileset({
          url: classifcationTilesetUrl,
          classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
        });
        classificationTileset.style = new Cesium.Cesium3DTileStyle({
          color: "rgba(255, 0, 0, 0.5)",
        });
        viewer.scene.primitives.add(classificationTileset);

        // The same b3dm tileset used for classification, but rendered normally for comparison.
        const nonClassificationTileset = new Cesium.Cesium3DTileset({
          url: classifcationTilesetUrl,
          show: false,
        });
        nonClassificationTileset.style = new Cesium.Cesium3DTileStyle({
          color: "rgba(255, 0, 0, 0.5)",
        });
        viewer.scene.primitives.add(nonClassificationTileset);

        Sandcastle.addToggleButton("Show classification", true, function (
          checked
        ) {
          classificationTileset.show = checked;
          nonClassificationTileset.show = !checked;
        });
        //Sandcastle_End
        Sandcastle.finishedLoading();
      }
      if (typeof Cesium !== "undefined") {
        window.startupCalled = true;
        startup(Cesium);
      }
    </script>
  </body>
</html>
